﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Microsoft.Synchronization.Data;
using Microsoft.Synchronization;
using System.Data.SqlClient;
using SyncLib.Data;

namespace SyncLib.Interface
{
    [ServiceContract]
    [ServiceKnownType(typeof(DbSyncContext))]
    [ServiceKnownType(typeof(SyncSchema))]
    [ServiceKnownType(typeof(WebSyncFaultException))]
    [ServiceKnownType(typeof(SyncIdFormatGroup))]
    [ServiceKnownType(typeof(SyncOrchestratorState))]
    [ServiceKnownType(typeof(SqlException))]
    public interface IRelationalSyncContract : ISyncConfigManager
    {
        #region KnowledgeSyncProvider Implement
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        void BeginSession(SyncProviderPosition position);
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        void EndSession();
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        KChangesParameter GetChangeBatch(uint batchSize, SyncKnowledge destinationKnowledge);
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        KChangesParameter GetFullEnumerationChangeBatch(uint batchSize, SyncId lowerEnumerationBound, SyncKnowledge knowledgeForDataRetrieval);
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        KSyncBatchParameter GetSyncBatchParameters();
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        SyncIdFormatGroup GetIdFormats();

        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        SyncSessionStatistics ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncSessionStatistics sessionStatistics);
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        SyncSessionStatistics ProcessFullEnumerationChangeBatch(Microsoft.Synchronization.ConflictResolutionPolicy resolutionPolicy, FullEnumerationChangeBatch sourceChanges, object changeDataRetriever, SyncSessionStatistics sessionStatistics);
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        Byte[] DownloadBatchFile(string fileName);
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        void UploadBatchFile(string batchFileId, byte[] batchContents, string remotePeerId);
        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        bool HasUploadedBatchFile(String batchFileId, string remotePeerId);


        [OperationContract]
        [FaultContract(typeof(WebSyncFaultException))]
        void ChangeState(SyncOrchestratorState state);
        #endregion
    }
}
